package com.db;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import java.io.PrintStream;

public class SpygDao extends ContentProvider {
	private static final String TABLE_NAME = "spygInfo";
	private DatabaseHelper dbHelper;

	public int delete(Uri paramUri, String paramString,
			String[] paramArrayOfString) {
		SQLiteDatabase localSQLiteDatabase = this.dbHelper
				.getWritableDatabase();
		localSQLiteDatabase.beginTransaction();
		int i = 0;
		try {
			i = localSQLiteDatabase.delete("spygInfo", paramString,
					paramArrayOfString);
			localSQLiteDatabase.setTransactionSuccessful();
			return i;
		} catch (Exception localException) {
			localException.printStackTrace();
			return i;
		} finally {
			localSQLiteDatabase.endTransaction();
			localSQLiteDatabase.close();
		}
	}

	public String getType(Uri paramUri) {
		return null;
	}

	public Uri insert(Uri paramUri, ContentValues paramContentValues) {
		SQLiteDatabase localSQLiteDatabase = this.dbHelper
				.getWritableDatabase();
		localSQLiteDatabase.beginTransaction();
		try {
			System.out.println("数据是：" + paramContentValues);
			localSQLiteDatabase.insert("spygInfo", null, paramContentValues);
			localSQLiteDatabase.setTransactionSuccessful();
			return paramUri;
		} catch (Exception localException) {
			localException.printStackTrace();
			return paramUri;
		} finally {
			localSQLiteDatabase.endTransaction();
			localSQLiteDatabase.close();
		}
	}

	public boolean onCreate() {
		this.dbHelper = new DatabaseHelper(getContext(), "SQlite.db", null, 1);
		return true;
	}

	public Cursor query(Uri paramUri, String[] paramArrayOfString1,
			String paramString1, String[] paramArrayOfString2,
			String paramString2) {
		return this.dbHelper.getReadableDatabase().query("spygInfo",
				paramArrayOfString1, paramString1, paramArrayOfString2, null,
				null, paramString2);
	}

	public int update(Uri paramUri, ContentValues paramContentValues,
			String paramString, String[] paramArrayOfString) {
		SQLiteDatabase localSQLiteDatabase = this.dbHelper
				.getWritableDatabase();
		localSQLiteDatabase.beginTransaction();
		int i = 0;
		try {
			i = localSQLiteDatabase.update("spygInfo", paramContentValues,
					paramString, paramArrayOfString);
			localSQLiteDatabase.setTransactionSuccessful();
			return i;
		} catch (Exception localException) {
			localException.printStackTrace();
			return i;
		} finally {
			localSQLiteDatabase.endTransaction();
			localSQLiteDatabase.close();
		}
	}
	
	
}